package com.hxx.controller;

import com.hxx.domain.TProduct;
import com.hxx.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private ProductService productService;

    @GetMapping("/{id}")
    public TProduct getProduct(@PathVariable Integer id){
        return productService.getById(id);
    }

    @GetMapping("/show1")
    public String show1(@RequestParam String name){
        return "product---show--name="+name;
    }

    @GetMapping("/show")
    public String show(){
        return "product---show--one";
    }

    @GetMapping("/show2")
    public String show2(@RequestParam String name,@RequestParam int age){
        return "product-name="+name+"---age-->"+age;
    }

    @PostMapping("/show4")
    public String show4(@RequestBody TProduct product){
        return "product-product="+product;
    }

    @PostMapping("/show6")
    public List show6(@RequestBody List<Integer> list){
        return list;
    }

    @PostMapping("/show5")
    public String show5(@RequestParam String name){
        return "product-name="+name;
    }
}




























